<template>
  <PageHeadFooter class="detail-slot" page="detail">
    <div class="crumbs">
      <div
        style="height: 100%"
        class="container flex-y-center font-18 color-fff"
      >
        <div
          style="height: 100%"
          class="m-x-40 flex-y-center font-18 color-fff"
        >
          <span @click="$router.push('/')" class="cspt m-r-4">HOME</span>
          <span class="m-r-4">>></span>
          <span @click="checkIndex = -1" class="cspt m-r-4"
            >CONTAINERS SPEC</span
          >
          <template v-if="checkIndex != -1">
            <span class="m-r-4">>></span>
            <span class="m-r-4">{{
              tsfmObj(detailData[checkIndex]).title
            }}</span>
          </template>
        </div>
      </div>
    </div>
    <div class="detail-page">
      <div v-if="checkIndex > -1" class="detail-box">
        <div class="left-img">
          <img :src="tsfmObj(detailData[checkIndex]).img_url" alt="" />
        </div>
        <div class="detail-msg flex-w-1">
          <div class="title">{{ tsfmObj(detailData[checkIndex]).title }}</div>
          <div class="title title_1">TECHNICAL SPECIFICATIONS</div>
          <div class="list flex">
            <div
              class="item flex-w-1"
              v-for="(item, i) in tsfmObj(detailData[checkIndex]).child"
              :key="i"
            >
              <div class="item-title">{{ item.title }}</div>
              <template v-for="(v, k) in item">
                <template v-if="k != 'title'">
                  <div :key="JSON.stringify(v)" class="item-p flex-x-sb">
                    <div>{{ k }}</div>
                    <div>{{ v }}</div>
                  </div>
                </template>
              </template>
              <!-- <div class="attr">{{ v }}</div> -->
            </div>
          </div>
        </div>
      </div>
      <div class="page-item">
        <div class="title">Mini Size Containers</div>
        <div class="list">
          <div
            class="item"
            @click="clickItem(i1)"
            :key="i1"
            v-for="(item1, i1) in detailData.slice(0, 11)"
          >
            <img :src="tsfmObj(item1).img_url" alt="" />
            <div class="img-mask">{{ tsfmObj(item1).title }}</div>
          </div>
        </div>
      </div>
      <div class="page-item">
        <div class="title">20'Container</div>
        <div class="list">
          <div
            class="item"
            @click="clickItem(11 + i1)"
            :key="i1"
            v-for="(item1, i1) in detailData.slice(11, 29)"
          >
            <img :src="tsfmObj(item1).img_url" alt="" />
            <div class="img-mask">{{ tsfmObj(item1).title }}</div>
          </div>
        </div>
      </div>
      <div class="page-item">
        <div class="title">40'Container</div>
        <div class="list">
          <div
            class="item"
            @click="clickItem(30 + i1)"
            :key="i1"
            v-for="(item1, i1) in detailData.slice(30, 40)"
          >
            <img :src="tsfmObj(item1).img_url" alt="" />
            <div class="img-mask">{{ tsfmObj(item1).title }}</div>
          </div>
        </div>
      </div>
      <div class="page-item">
        <div class="title">Over Size Containers</div>
        <div class="list">
          <div
            class="item"
            @click="clickItem(40 + i1)"
            :key="i1"
            v-for="(item1, i1) in detailData.slice(40, 44)"
          >
            <img :src="tsfmObj(item1).img_url" alt="" />
            <div class="img-mask">{{ tsfmObj(item1).title }}</div>
          </div>
        </div>
      </div>
    </div>
  </PageHeadFooter>
</template>

<script>
import PageHeadFooter from "../index/components/page-head-footer.vue";
import { data } from "./res.js";
import "@/assets/js/flexible.js";

export default {
  components: {
    PageHeadFooter,
  },
  data() {
    return {
      detailData: data,
      checkIndex: -1,
    };
  },
  computed: {
    tsfmObj() {
      return function (obj) {
        var data = {
          title: "",
          img_url: "",
          child: [],
        };
        for (const key in obj) {
          data.title = key;
          for (const key1 in obj[key]) {
            if (key1 == "img_url") {
              data.img_url = obj[key][key1];
            } else {
              data.child.push({
                title: key1,
                ...obj[key][key1],
              });
            }
          }
        }
        // console.log(data);
        // data.data.img_url = require(data.data.img_url);
        // console.log(data.data.img_url);
        return data;
      };
    },
  },
  methods: {
    clickItem(index) {
      this.checkIndex = index;
      let detailDom = document.querySelector(".detail-page .detail-box");
      window.scrollTo({ top: 0 });
    },
  },
};
</script>

<style lang="scss" scoped>
@media (min-width: 768px) {
  .container {
    width: 740px;
  }
}
@media (min-width: 992px) {
  .container {
    width: 960px;
  }
}
@media (min-width: 1280px) {
  .container {
    width: 1200px;
  }
}
@media (min-width: 1600px) {
  .container {
    width: 1560px;
  }
}
@media (min-width: 1920px) {
  .container {
    width: 1800px;
  }
}
// @media (min-width: 1920px) {
.detail-slot {
  .detail-page {
    margin: 0 auto;
    padding-left: 40px;
    padding-right: 40px;
    box-sizing: border-box;
    > div {
      // .box-start {
      margin-top: 30px;
      padding-bottom: 40px;
      border-bottom: 1px solid #ddd;
      // }
    }
  }

  .crumbs {
    height: 60px;
    border-top: 2px;
    background: url("./continer_img/crumbs-bg.jpg") repeat center center;
  }

  .detail-box {
    display: flex;
    .left-img {
      margin-right: 40px;
      width: 400px;
      > img {
        width: 100%;
      }
    }
    .title {
      font-size: 20px;
      font-weight: 600;
      line-height: 40px;
    }
    .title_1 {
      font-size: 16px;
      margin-top: 5px;
    }

    .list {
      .item {
        margin-right: 20px;
        .item-title {
          font-weight: 600;
          font-size: 12px;
          line-height: 1.7;
          border-bottom: 1px solid #bbb;
        }
        .item-p {
          font-size: 12px;
          line-height: 1.7;
          border-bottom: 1px solid #bbb;
        }
      }
    }
  }
  .page-item {
    .title {
      line-height: 1.7;
      font-size: 16px;
    }
    .list {
      margin-top: 10px;
      display: flex;
      flex-wrap: wrap;
      .item {
        position: relative;
        margin-right: 15px;
        margin-bottom: 20px;
        width: calc(25% - 15px);
        overflow: hidden;
        > img {
          width: 100%;
          height: 270px;
          object-fit: cover;
        }
        .img-mask {
          display: table-cell;

          position: absolute;
          left: 0;
          top: 0;
          width: 100%;
          height: 100%;
          background: rgba($color: #000000, $alpha: 0.5);

          display: flex;
          align-items: center;
          justify-content: center;
          color: #fff;
          font-weight: 600;
          font-size: 20px;
        }
        &:hover {
          .img-mask {
            top: -100%;
            transition: top 0.3s linear;
          }
        }
      }
    }
  }
}
// }
</style>
